<%--
  Created by IntelliJ IDEA.
  User: asus
  Date: 2020/6/4
  Time: 8:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="true" %>
<html>
<head>
    <title>盘盈盘亏审核</title>
    <%@include file="/comm/head.jsp"%>
</head>
<body>
<div id="root">

    <Collapse value="search">
        <Panel name="search">
            条件查询
            <p slot="content">
                <i-form inline :label-width="70">

                    <form-item label="登记日期:">
                        <row>
                            <col span="12"> <date-picker @on-change="pkykVo.startDate=$event"  placeHolder="请输入起始日期" style="width: 150px" type="date" ></date-picker></col>
                            <col span="12"> <date-picker @on-change="pkykVo.endDate=$event"   placeHolder="请输入结束日期" style="width: 150px" type="date" ></date-picker></col>
                        </row>
                    </form-item>
                    <form-item label="审核日期:">
                        <row>
                            <col span="12"> <date-picker @on-change="pkykVo.startDate2=$event"  placeHolder="请输入起始日期" style="width: 150px" type="date" ></date-picker></col>
                            <col span="12"> <date-picker @on-change="pkykVo.endDate2=$event"   placeHolder="请输入结束日期" style="width: 150px" type="date" ></date-picker></col>
                        </row>
                    </form-item>
                    <form-item label="类型:" prop="type">
                        <radio-group v-model="pkykVo.type">
                            <radio :label="1">盘盈</radio>
                            <radio :label="2">盘亏</radio>
                        </radio-group>
                    </form-item>
                    <i-button type="primary" style="margin-left:20px" @click="pageNo=1;search();">搜索</i-button>
                </i-form>
            </p>
        </Panel>
    </Collapse>
    <i-table :columns="columns" :data="pageResult.rows"  :height="300"  @on-selection-change="tableSelection=arguments[0]"  border stripe>
        <template slot-scope="{row}" slot="name">
            <span>{{row.goods.name}}</span>
        </template>
        <template slot-scope="{row}" slot="sname">
            <span>{{row.store.sname}}</span>
        </template>
        <template slot-scope="{row}" slot="username">
            <span>{{row.user.username}}</span>
        </template>
        <template slot-scope="{row}" slot="state">
            <span>{{row.state==0?"未审核":"已审核"}}</span>
        </template>
        <template slot-scope="{row}" slot="type">
            <span>{{row.type==1?"盘盈":"盘亏"}}</span>
        </template>
        <template slot-scope="{row,index}"  slot="action">
            <i-button type="warning" @click="searchRow(row,index)">详 情</i-button>
            <%--<i-button type="warning" @click="update(row,index)">审 核</i-button>--%>
        </template>
    </i-table>
    <modal v-model="searchFlag" title="盘盈盘亏审核"   @on-ok="update">
        <i-form :label-width="80" style="padding: 30px" >
            <form-item label="编号" >
                <i-input v-model="shen.id"  readonly/>
            </form-item>
            <form-item label="登记日期">
                <i-input v-model="shen.createtime" readonly/>
            </form-item>
            <form-item label="商品">
                <i-input v-model="shen.name" readonly/>
            </form-item>
            <form-item label="仓库" >
                <i-input v-model="shen.sname"  readonly/>
            </form-item>
            <form-item label="数量" >
                <i-input v-model="shen.num"  readonly/>
            </form-item>
            <form-item label="类型" >
                <i-input v-model="shen.typeName"    readonly/>

            </form-item>
            <form-item label="备注" >
                <i-input v-model="shen.remark"  readonly/>
            </form-item>
        </i-form>

    </modal>

    <Page :total="pageResult.total"
          :page-size="pageSize"
          @on-change="pageNo=arguments[0];search();"
          show-sizer
          :page-size-opts="[5,10,15]"
          @on-page-size-change="pageSize=arguments[0];search();"
    />


</div>

<script>

    new Vue({
        el:"#root",
        data:{

            columns:[
                { key:"id",title:"编号"},
                {slot:"sname",title:"商品仓库"},
                {slot:"name",title:"商品名称"},
                {title:"数量",key: "num"},
                {title:"类型",slot: "type"},
                {title:"登记日期",key: "createtime"},
               // {title:"审核日期",key: "checktime"},
                {title:"登记人",slot: "username"},
                // {title:"审核人",slot: "username"},
                {title:"状态",slot: "state"},
                {title: "操作", slot: "action", width: 300}
            ],
            columns1:[
                { key:"id",title:"编号"},
                {slot:"sname",title:"商品仓库"},
                {slot:"name",title:"商品名称"},
                {title:"数量",key: "num"},
                {title:"类型",slot: "type"},
                {title:"登记日期",key: "createtime"},
                // {title:"审核日期",key: "checktime"},
                {title:"登记人",slot: "username"},
                // {title:"审核人",slot: "username"},
                {title:"备注",key: "remark"},
            ],
            pageResult:{
                rows:[],
                total:50
            },
            pageNo:1,
            pageSize:5,
            data2:[],
            tableSelection:[],
            pkykVo:{},
            panyingpankui:{},
            searchFlag:false,
            shen:{
                id:"",
                createTime:"",
                goodsId:"",
                storeId:"",
                num:"",
                typeName:"",
                remark:"",
                name:'',
                sname:'',




            },

        },
        methods:{
            search(){
                axios.get(`${ctx}/kucun/pkyk/searchAll/${this.pageNo}/${this.pageSize}`)
                    .then(({data})=>{
                        this.pageResult=data.result;
                    });
            },
            searchRow(row,index){
                this.searchFlag=true;
                axios.get(`${ctx}/kucun/pkyk/list?id=${row.id}`)
                    .then(({data})=>{
                        this.shen=data.result;
                       this.shen.name= this.shen.goods.name;
                       this.shen.sname=this.shen.store.sname;
                     this.shen.goodId = this.shen.goodsId;
                    this.shen.storeId =this.shen.storeId;
                    this.shen.number=this.shen.num;
                    this.shen.type=this.shen.type;
                        if(this.shen.type==2){
                            this.shen.typeName="盘亏";
                        }else if(this.shen.type==1){
                            this.shen.typeName="盘盈";
                        }
                        console.log(this.shen)
                        this.search();
                    });
            },
            update(){
                axios.post(`${ctx}/kucun/pkyk/update`,this.shen)
                    .then(({data})=>{

                        this.searchFlag=false;
                        iview.Message.success({content:data.msg});
                        this.search();


                    });
            },

        },
        mounted(){
            this.search();
        }
    });
</script>
</body>
</html>
